import modelEntity from "../modelEntity";
export default class Market extends modelEntity {
  constructor(options) {
    super(options);
    this.CompetProduct_Name = options.CompetProduct_Name;
    this.GetTime = options.GetTime;
    this.VolumeRate = options.VolumeRate;
    this.CalVolumeRate = options.CalVolumeRate;
    this.FloorMoney = options.FloorMoney;
    this.Ref_Business_Guids = options.Ref_Business_Guids;
    this.FirstTime = options.FirstTime;
    this.NowMoney = options.NowMoney;
    this.NowMonth_QuhuaTaoshu = options.NowMonth_QuhuaTaoshu;
    this.NowMonth_QuhuaTaoshu_Average = options.NowMonth_QuhuaTaoshu_Average;
    this.NowMonth_Aera = options.NowMonth_Aera;
    this.NowMonth_Area_Average = options.NowMonth_Area_Average;

    this.businessTypeDef = options.businessTypeDef;
    this.businessTypeDefName = "";
    if (this.businessTypeDef) {
      this.businessTypeDefName = this.businessTypeDef.Business_Type;
    }
    this.basePath = "市场";
  }
  static newInstance() {
    return new Market({
      CompetProduct_Name: null,
      GetTime: null,
      VolumeRate: null,
      CalVolumeRate: null,
      FloorMoney: null,
      Ref_Business_Guids: null,
      FirstTime: null,
      NowMoney: null,
      NowMonth_QuhuaTaoshu: null,
      NowMonth_QuhuaTaoshu_Average: null,
      NowMonth_Aera: null,
      NowMonth_Area_Average: null,
      basePath: "市场",
      fileResult: []

    })
  }
  static loadList() {
    return new Promise((resolve, reject) => {
      window.api.http_get("/api/prj/market?prj=" + window.nowPrj.pCode)
        .then(
          res => {
            console.log(res);
            let list = [];
            res.forEach(x => {
              list.push(new Market(x));
            });
            resolve(list);
          }
        )
    })
  }
  create() {
    return new Promise((resolve, reject) => {
      window.api.http_post("/api/prj/market?prj=" + window.nowPrj.pCode, this)
        .then(
          res => {
            let model = new Market(res);
            resolve(model);
          }
        )
    })
  }
  delete() {
    return new Promise((resolve, reject) => {
      window.api.http_delete("/api/prj/market?prj=" + window.nowPrj.pCode, this)
        .then(
          res => {
            resolve(res);
          }
        )
    })
  }
  modify() {
    return new Promise((resolve, reject) => {
      window.api.http_put("/api/prj/market?prj=" + window.nowPrj.pCode, this)
        .then(
          res => {
            let model = new Market(res);
            resolve(model);
          }
        )
    })
  }
}
